#include "logger.h"

Logger* Logger::logger = NULL;

Logger& Logger::getInstance(){
    if(!logger)
        logger = new Logger;
    return(*logger);
}

Logger::Logger(){
    file = new QFile("./Segmentator.log");
    bool ok = file->open(QIODevice::Append | QIODevice::WriteOnly | QIODevice::Text);
    logOut = new QTextStream(file);
    *logOut << "Start logging";
}

Logger::~Logger(){
    file->close();
}

QTextStream& wrLog(){
    (*(Logger::getInstance().logOut)) << QDateTime::currentDateTime().toString()+": ";
    return(*(Logger::getInstance().logOut));
}
